import util from "../util/Util.js";
var cartCtrl = {};
cartCtrl.cartInfoHandler = function(arr,setSellData)
{
	let len = arr.length;
	let ary = [];
	for(let i = len-1; i>=0; i--) //新增加的在前面
	{
		let o = arr[i];
		if(o.spec_unit_ls)
		{
			let tempArr = o.spec_unit_ls;
			let leng = tempArr.length;
			for(let j = leng - 1; j >=0 ; j--)
			{
				let oo = tempArr[j];
				let temp = {};
				temp.num_p = setSellData ? setSellData.num_p : 2;//数量小数位
				
				temp.money_p = setSellData ? setSellData.money_p : 2;//价格小数位
				temp.num_min = setSellData ? setSellData.num_min : 1; //产品起订量，对于每个sku
				temp.num_step = setSellData ? setSellData.num_step : 1 //步长;
				//产品公共属性
				temp.brand_ls = o.brand_ls;
				temp.buymin = util.decimalPlaceCount(Number(o.buymin),temp.num_p);
				temp.cat_dir = o.cat_dir;
				temp.cat_lever = o.cat_lever;
				temp.catid = o.catid;
				temp.cattitle = o.cattitle;
				temp.cost_quote_type = o.cost_quote_type;
				temp.gdid = o.gdid;
				temp.gdname = o.gdname;
				temp.img = o.img;
				temp.item_no = o.item_no;
				temp.onsale = o.onsale;
				temp.price_quote_type = o.price_quote_type;
				//规格，单位
				temp.discount_r = util.decimalPlaceCount(Number(oo.discount_r),temp.num_p);
				temp.id = oo.id;
				temp.nosale = oo.nosale;
				temp.number = util.decimalPlaceCount(Number(oo.number),temp.num_p);
				temp.price = util.decimalPlaceCount(Number(oo.price),temp.money_p);
				temp.price_0 = util.decimalPlaceCount(Number(oo.price_0),temp.money_p);
				temp.price_i = util.decimalPlaceCount(Number(oo.price_i),temp.money_p);
				temp.spec_dir = oo.spec_dir;
				temp.spec_title = oo.spec_title;
				temp.specid = oo.specid;
				temp.txt = oo.txt;
				temp.unit_title = oo.unit_title;
				temp.unitid = oo.unitid;
				temp.showMenu = false;
				ary.push(temp);
			}
		}
	}
	return ary;
}
export default cartCtrl;